/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "ExemplaireReservation")
@NamedQueries({
    @NamedQuery(name = "ExemplaireReservation.findAll", query = "SELECT e FROM ExemplaireReservation e"),
    @NamedQuery(name = "ExemplaireReservation.findByNumeroArticle", query = "SELECT e FROM ExemplaireReservation e WHERE e.exemplaireReservationPK.numeroArticle = :numeroArticle"),
    @NamedQuery(name = "ExemplaireReservation.findByDateMiseADisposition", query = "SELECT e FROM ExemplaireReservation e WHERE e.dateMiseADisposition = :dateMiseADisposition"),
    @NamedQuery(name = "ExemplaireReservation.findByIdReservation", query = "SELECT e FROM ExemplaireReservation e WHERE e.exemplaireReservationPK.idReservation = :idReservation")})
public class ExemplaireReservation implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ExemplaireReservationPK exemplaireReservationPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateMiseADisposition", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateMiseADisposition;
    @JoinColumn(name = "idReservation", referencedColumnName = "idReservation", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Reservation reservation;
    @JoinColumn(name = "NumeroArticle", referencedColumnName = "NumeroArticle", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Exemplaire exemplaire;

    public ExemplaireReservation() {
    }

    public ExemplaireReservation(ExemplaireReservationPK exemplaireReservationPK) {
        this.exemplaireReservationPK = exemplaireReservationPK;
    }

    public ExemplaireReservation(ExemplaireReservationPK exemplaireReservationPK, Date dateMiseADisposition) {
        this.exemplaireReservationPK = exemplaireReservationPK;
        this.dateMiseADisposition = dateMiseADisposition;
    }

    public ExemplaireReservation(int numeroArticle, int idReservation) {
        this.exemplaireReservationPK = new ExemplaireReservationPK(numeroArticle, idReservation);
    }

    public ExemplaireReservationPK getExemplaireReservationPK() {
        return exemplaireReservationPK;
    }

    public void setExemplaireReservationPK(ExemplaireReservationPK exemplaireReservationPK) {
        this.exemplaireReservationPK = exemplaireReservationPK;
    }

    public Date getDateMiseADisposition() {
        return dateMiseADisposition;
    }

    public void setDateMiseADisposition(Date dateMiseADisposition) {
        this.dateMiseADisposition = dateMiseADisposition;
    }

    public Reservation getReservation() {
        return reservation;
    }

    public void setReservation(Reservation reservation) {
        this.reservation = reservation;
    }

    public Exemplaire getExemplaire() {
        return exemplaire;
    }

    public void setExemplaire(Exemplaire exemplaire) {
        this.exemplaire = exemplaire;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (exemplaireReservationPK != null ? exemplaireReservationPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ExemplaireReservation)) {
            return false;
        }
        ExemplaireReservation other = (ExemplaireReservation) object;
        if ((this.exemplaireReservationPK == null && other.exemplaireReservationPK != null) || (this.exemplaireReservationPK != null && !this.exemplaireReservationPK.equals(other.exemplaireReservationPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.ExemplaireReservation[ exemplaireReservationPK=" + exemplaireReservationPK + " ]";
    }
    
}
